package com.zero.book;

import java.util.*;

import static com.zero.book.constant.SelectConstant.*;
import static com.zero.book.message.MessageConstant.*;
import static com.zero.book.utils.PrintUtil.*;
import static com.zero.book.utils.CatchEnter.*;


import static com.zero.book.service.DevelopService.*;
import static com.zero.book.service.CRUDService.*;

/**
 * @author Zero
 * @version 1.0.0
 * @date 2025/01/19
 * @description 终端图书管理系统
 * @since 2025/01/19 10:09
 */
@SuppressWarnings("all")
//TODO 输入的异常操作
public class Main {

    /**
     * 程序入口
     *
     * @param args args
     */
    public static void main(String[] args) {
        //scan
        Scanner sc = new Scanner(System.in);
        //loop condition
        boolean loop = true;
        //menu
        while (loop) {
            print(WELCOME);
            print(ENTRY_MES);
            print(QUERY_MES);
            print(DELETE_MES);
            print(MODIFY_MES);
            print(EXIT_MES);
            print(DEVELOPER_MES);
            print(INPUT_MES);
            //waiting for user input
            if (!EnterChoice(sc, DEVELOPER_MES, EXIT_MES)) {
                continue;
            }
            switch (getData()) {
                case ENTRY:
                    Entry(sc);
                    break;
                case QUERY:
                    Query(sc);
                    break;
                case DELETE:
                    Delete(sc);
                    break;
                case MODIFY:
                    Modify(sc);
                    break;
                case EXIT:
                    print("GoodBye");
                    loop = false;
                    sc.close();
                    break;
                case DEVELOPER_MODE:
                    DevelopMode(sc);
                    break;
                default:
                    print(INPUT_ERROR);
                    break;
            }
        }
        System.exit(0);
    }
}
